var tmpArr;
var QueryString;
var URL = document.location.toString();

URL = decodeURI(URL);

var counts;

var value_array ;

if (URL.lastIndexOf("?") != -1) {

	QueryString = URL.substring(URL.lastIndexOf("?") + 1, URL.length);

	counts = QueryString.substring(QueryString.indexOf("?") + 8, QueryString.indexOf("&"));

	QueryString = URL.substring(URL.indexOf("&") + 1, URL.length);

	tmpArr = new Array();

	tmpArr = QueryString.split("&");
	
	value_array = new Array();

}

function item_click(i) {

	alert("===" + i);

}


window.onload = function() {

	var list = document.getElementById("list");

	var item_array = new Array();

	var p_array = new Array();

	for (var i = 1; i <= counts; i++) {

		item_array[i] = document.createElement("li");
		item_array[i].setAttribute("class", "item_li");
		list.appendChild(item_array[i]);

		p_array[0] = document.createElement("p");
		var p0 = tmpArr[3 * (i - 1) + 0].substring(0, tmpArr[3 * (i - 1) + 0].indexOf("="));
		if (p0 == "person_name") {
			value_array[0 + (i-1)*3] = tmpArr[3 * (i - 1) + 0].substring(tmpArr[3 * (i - 1) + 0].indexOf("=") + 1, tmpArr[3 * (i - 1) + 0].length);
			p_array[0].textContent = value_array[0 + (i-1)*3];
		}
		item_array[i].appendChild(p_array[0]);

		p_array[1] = document.createElement("p");
		var p1 = tmpArr[3 * (i - 1) + 1].substring(0, tmpArr[3 * (i - 1) + 1].indexOf("="));
		if (p1 == "phone") {
			value_array[1 + (i-1)*3] = tmpArr[3 * (i - 1) + 1].substring(tmpArr[3 * (i - 1) + 1].indexOf("=") + 1, tmpArr[3 * (i - 1) + 1].length);
			p_array[1].textContent = value_array[1 + (i-1)*3];
		}
		item_array[i].appendChild(p_array[1]);

		p_array[2] = document.createElement("p");
		var p2 = tmpArr[3 * (i - 1) + 2].substring(0, tmpArr[3 * (i - 1) + 2].indexOf("="));
		if (p2 == "addr") {
			value_array[2 + (i-1)*3] = tmpArr[3 * (i - 1) + 2].substring(tmpArr[3 * (i - 1) + 2].indexOf("=") + 1, tmpArr[3 * (i - 1) + 2].length);
			p_array[2].textContent = value_array[2 + (i-1)*3];
		}
		item_array[i].appendChild(p_array[2]);


		item_array[i].style.paddingTop = "10px";
		item_array[i].style.marginLeft = "15px";

		var hr = document.createElement("hr");
		item_array[i].appendChild(hr);
		hr.style.borderBottomWidth = "0.5px";

	}


	var item_lists = document.getElementsByTagName("li");

	var funny = function(i) {
		item_lists[i].onclick = function() {
			window.location.href = "pratice.html?person_name="+value_array[3*i+0]+"&phone="+value_array[3*i+1]+"&addr="+value_array[3*i+2];
		}
	}
	for (var i = 0; i < item_lists.length; i++) {
		funny(i);
	}


}